package com.dorado.example.mq.consumer;

import com.dorado.example.dto.TestModelDTO;
import com.dorado.kernel.core.annotation.Provider;
import com.dorado.kernel.messaging.annotation.MQConsumer;
import com.dorado.kernel.messaging.annotation.MQConsumerMode;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Provider(value = "orderMqService", clazz = OrderMqServiceImpl.class)
@Slf4j
public class OrderMqServiceImpl {

    @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_ORDER", topic ="order_mq"  , tags = "create1")
    public void  sendMsg(TestModelDTO order) {
        log.info("订阅者消费消息，sendMsg1111=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg1=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg11111=========单个的========{}", order);
    }

    @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_ORDER_ARRAY", topic ="order_mq"  , tags = "create2")
    public void  sendMsg2(TestModelDTO order) {
        log.info("订阅者消费消息，sendMsg22222=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg=========单个的========{}", order);
        log.info("订阅者消费消息，sendMsg22222=========单个的========{}", order);
    }

    @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_ORDER_LIST", topic ="order_mq_list", tags = "list" , recordTable = "mq_record_noshar" , mqConsumerMode = @MQConsumerMode(value=MQConsumerMode.Mode.BATCH))
    public void sendListMsg(List<TestModelDTO> order) {
        log.info("=======批量消费==========");
        log.info("订阅者消费消息，sendList================={}", order);
    }

/*
    @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_ORDER", topic ="order_mq_array", tags = "array", mqConsumerMode = @MQConsumerMode(value=MQConsumerMode.Mode.BATCH) )
    public void sendArrayMsg(OrderModelVo[] order) {
        log.info("订阅者消费消息，sendArray================={}", JSONUtils.toJSONString(order));
    }*/

    /**
     * 普通消息生产者-调用
     */
/*    @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_TX", topic ="order_tx_mq", tags = "create", recordTable = "mq_record_idempotent" )
    public void  sendTXMsg(OrderModelVo order, String tt, OrderModelVo[] vo) {
        log.info("订阅者消费消息，sendTXMsg=========单个的========{}", order);
    }
*/
    /**
     * 单向消息生产者-调用
     */
/*   @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_ORDER", topic ="order_mq_oneway", tags = "create")
   public void sendOneWayMsg(OrderModelVo order) {
        log.info("订阅者消费消息，sendOneWayMsg================={}", order);
    }*/

    /**
     * 顺序消息生产者-调用
     */
/*   @MQConsumer(name = "RocketMQ1", groupName ="HYDRA_ORDER_ORDERLY", topic ="order_orderly_mq", tags = "create", recordTable = "mq_record_idempotent")
   public void sendOrderlyMsg(OrderModelVo order) {
        log.info("订阅者消费消息，sendOrderlyMsg================={}", order);
    }*/
}